package com.turing.post.capitalaccounts.util;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.turing.post.util.PCPSUtil;

/**
 * 销售机构资金明细
 * 
 * @author 李治
 * 
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "SALECAPITALDETAIL")
@IdClass(SaleCapitalDetail.class)
public class SaleCapitalDetail implements Serializable {
	/**
	 * 销售机构号
	 */
	private String saleBranchNo;
	/**
	 * 日期
	 */
	private Date tranDate;
	/**
	 * 交易类型
	 */
	private String tranType;
	/**
	 * 相关业务单ID
	 */
	private BigInteger ticketId;
	/**
	 * 交易时间
	 */
	private Date tranTime;
	/**
	 * 信用度存入
	 */
	private BigInteger creditDeposit;
	/**
	 * 信用度支出
	 */
	private BigInteger creditWithdraw;
	/**
	 * 现金存入
	 */
	private BigInteger cashDeposit;
	/**
	 * 现金支出
	 */
	private BigInteger cashWithdraw;
	/**
	 * 操作员ID
	 */
	private BigInteger operId;
	/**
	 * 摘要
	 */
	private String remark;
	/**
	 * 预存款
	 */
	public static final String TRANTYPE_DEPOSIT = "00";
	/**
	 * 预存款取消
	 */
	public static final String TRANTYPE_CANCELDEPOSIT = "10";
	/**
	 * 激活
	 */
	public static final String TRANTYPE_ACTIVATE = "01";
	/**
	 * 激活取消
	 */
	public static final String TRANTYPE_CANCELACTIVATE = "11";
	/**
	 * 现金充值
	 */
	public static final String TRANTYPE_CASH_DEPOSIT = "03";
	/**
	 * 现金充值取消
	 */
	public static final String TRANTYPE_CANCEL_CASH_DEPOSIT = "13";
	/**
	 * 调整
	 */
	public static final String TRANTYPE_ADJUST = "02";
	/**
	 * 收到现金
	 */
	public static final String TRANTYPE_RECEIVECASH = "05";
	/**
	 * 收到现金取消
	 */
	public static final String TRANTYPE_CANCELRECEIVECASH = "15";
	/**
	 * 上存现金
	 */
	public static final String TRANTYPE_DEPOSITCASH = "06";
	/**
	 * 上存现金取消
	 */
	public static final String TRANTYPE_CANCELDEPOSITCASH = "16";

	public SaleCapitalDetail() {

	}

	@Column(name = "SALEBRANCHNO", nullable = false)
	public String getSaleBranchNo() {
		return saleBranchNo;
	}

	public void setSaleBranchNo(String saleBranchNo) {
		this.saleBranchNo = saleBranchNo;
	}

	@Column(name = "TRANDATE", nullable = false)
	public Date getTranDate() {
		return tranDate;
	}

	public void setTranDate(Date tranDate) {
		this.tranDate = tranDate;
	}

	@Column(name = "TRANTYPE", nullable = false)
	public String getTranType() {
		return tranType;
	}

	public void setTranType(String tranType) {
		this.tranType = tranType;
	}

	@Id
	@Column(name = "TICKETID", nullable = false)
	public BigInteger getTicketId() {
		return ticketId;
	}

	public void setTicketId(BigInteger ticketId) {
		this.ticketId = ticketId;
	}

	@Id
	@Column(name = "TRANTIME", nullable = false)
	public Date getTranTime() {
		return tranTime;
	}

	public void setTranTime(Date tranTime) {
		this.tranTime = tranTime;
	}

	@Column(name = "CREDITDEPOSIT", nullable = false)
	public BigInteger getCreditDeposit() {
		return creditDeposit;
	}

	public void setCreditDeposit(BigInteger creditDeposit) {
		this.creditDeposit = creditDeposit;
	}

	@Column(name = "CREDITWITHDRAW", nullable = false)
	public BigInteger getCreditWithdraw() {
		return creditWithdraw;
	}

	public void setCreditWithdraw(BigInteger creditWithdraw) {
		this.creditWithdraw = creditWithdraw;
	}

	@Column(name = "CASHDEPOSIT", nullable = false)
	public BigInteger getCashDeposit() {
		return cashDeposit;
	}

	public void setCashDeposit(BigInteger cashDeposit) {
		this.cashDeposit = cashDeposit;
	}

	@Column(name = "CASHWITHDRAW", nullable = false)
	public BigInteger getCashWithdraw() {
		return cashWithdraw;
	}

	public void setCashWithdraw(BigInteger cashWithdraw) {
		this.cashWithdraw = cashWithdraw;
	}

	@Column(name = "OPERID", nullable = false)
	public BigInteger getOperId() {
		return operId;
	}

	public void setOperId(BigInteger operId) {
		this.operId = operId;
	}

	@Column(name = "REMARK", nullable = false)
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime
				* result
				+ ((this.getTicketId() == null) ? 0 : this.getTicketId()
						.hashCode());
		result = prime
				* result
				+ ((this.getTranTime() == null) ? 0 : this.getTranTime()
						.hashCode());

		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof SaleCapitalDetail))
			return false;

		SaleCapitalDetail other = (SaleCapitalDetail) obj;

		if (!PCPSUtil.compareObject(this.getTicketId(), other.getTicketId()))
			return false;

		return PCPSUtil.compareObject(this.getTranTime(), other.getTranTime());
	}
}
